/*********************************************************************
	Rhapsody	: 8.0
	Login		: Andrzej
	Component	: DefaultComponent
	Configuration 	: DefaultConfig
	Model Element	: DecisionMaker
//!	Generated Date	: Fri, 14, Dec 2012 
	File Path	: DefaultComponent/DefaultConfig/Default/DecisionMaker.java
*********************************************************************/

package Default;

//## auto_generated
import com.ibm.rational.rhapsody.oxf.*;
//## auto_generated
import com.ibm.rational.rhapsody.oxf.states.*;

//----------------------------------------------------------------------------
// Default/DecisionMaker.java                                                                  
//----------------------------------------------------------------------------

//## package Default 


//## class DecisionMaker 
public class DecisionMaker implements RiJStateConcept {
    
    public Reactive reactive;		//## ignore 
    
    protected boolean isBroken = false;		//## attribute isBroken 
    
    protected AC itsAC;		//## classInstance itsAC 
    
    protected Heater itsHeater;		//## classInstance itsHeater 
    
    protected TemperatureMeasurer itsTemperatureMeasurer;		//## classInstance itsTemperatureMeasurer 
    
    //#[ ignore 
    public static final int RiJNonState=0;
    public static final int Workflow=1;
    public static final int state_2=2;
    public static final int Work=3;
    public static final int terminationstate_10=4;
    public static final int Begin=5;
    public static final int state_13=6;
    public static final int AwaitModules=7;
    public static final int terminationstate_16=8;
    public static final int AwaitModule=9;
    public static final int state_1=10;
    public static final int AwaitMalfunctions=11;
    public static final int terminationstate_8=12;
    public static final int ShuttingDown=13;
    public static final int AwaitMalfunction=14;
    //#]
    protected int rootState_subState;		//## ignore 
    
    protected int rootState_active;		//## ignore 
    
    protected int state_2_subState;		//## ignore 
    
    protected int state_2_active;		//## ignore 
    
    public static final int DecisionMaker_Timeout_Begin_id = 1;		//## ignore 
    
    protected int state_13_subState;		//## ignore 
    
    protected int state_13_active;		//## ignore 
    
    protected int AwaitModules_subState;		//## ignore 
    
    public static final int DecisionMaker_Timeout_AwaitModules_id = 2;		//## ignore 
    
    protected int state_1_subState;		//## ignore 
    
    protected int state_1_active;		//## ignore 
    
    protected int AwaitMalfunctions_subState;		//## ignore 
    
    public static final int DecisionMaker_Timeout_ShuttingDown_id = 3;		//## ignore 
    
    
    //## statechart_method 
    public RiJThread getThread() {
        return reactive.getThread();
    }
    
    //## statechart_method 
    public void schedTimeout(long delay, long tmID, RiJStateReactive reactive) {
        getThread().schedTimeout(delay, tmID, reactive);
    }
    
    //## statechart_method 
    public void unschedTimeout(long tmID, RiJStateReactive reactive) {
        getThread().unschedTimeout(tmID, reactive);
    }
    
    //## statechart_method 
    public boolean isIn(int state) {
        return reactive.isIn(state);
    }
    
    //## statechart_method 
    public boolean isCompleted(int state) {
        return reactive.isCompleted(state);
    }
    
    //## statechart_method 
    public RiJEventConsumer getEventConsumer() {
        return (RiJEventConsumer)reactive;
    }
    
    //## statechart_method 
    public void gen(RiJEvent event) {
        reactive._gen(event);
    }
    
    //## statechart_method 
    public void queueEvent(RiJEvent event) {
        reactive.queueEvent(event);
    }
    
    //## statechart_method 
    public int takeEvent(RiJEvent event) {
        return reactive.takeEvent(event);
    }
    
    // Constructors
    
    //## auto_generated 
    public  DecisionMaker(RiJThread p_thread) {
        reactive = new Reactive(p_thread);
        initRelations(p_thread);
    }
    
    //## auto_generated 
    public boolean getIsBroken() {
        return isBroken;
    }
    
    //## auto_generated 
    public void setIsBroken(boolean p_isBroken) {
        isBroken = p_isBroken;
    }
    
    //## auto_generated 
    public AC getItsAC() {
        return itsAC;
    }
    
    //## auto_generated 
    public void __setItsAC(AC p_AC) {
        itsAC = p_AC;
    }
    
    //## auto_generated 
    public void _setItsAC(AC p_AC) {
        if(itsAC != null)
            {
                itsAC.__setParent(null);
            }
        __setItsAC(p_AC);
    }
    
    //## auto_generated 
    public AC newItsAC(RiJThread p_thread) {
        itsAC = new AC(p_thread);
        itsAC._setParent(this);
        return itsAC;
    }
    
    //## auto_generated 
    public void deleteItsAC() {
        itsAC.__setParent(null);
        itsAC=null;
    }
    
    //## auto_generated 
    public Heater getItsHeater() {
        return itsHeater;
    }
    
    //## auto_generated 
    public void __setItsHeater(Heater p_Heater) {
        itsHeater = p_Heater;
    }
    
    //## auto_generated 
    public void _setItsHeater(Heater p_Heater) {
        if(itsHeater != null)
            {
                itsHeater.__setParent(null);
            }
        __setItsHeater(p_Heater);
    }
    
    //## auto_generated 
    public Heater newItsHeater(RiJThread p_thread) {
        itsHeater = new Heater(p_thread);
        itsHeater._setParent(this);
        return itsHeater;
    }
    
    //## auto_generated 
    public void deleteItsHeater() {
        itsHeater.__setParent(null);
        itsHeater=null;
    }
    
    //## auto_generated 
    public TemperatureMeasurer getItsTemperatureMeasurer() {
        return itsTemperatureMeasurer;
    }
    
    //## auto_generated 
    public void __setItsTemperatureMeasurer(TemperatureMeasurer p_TemperatureMeasurer) {
        itsTemperatureMeasurer = p_TemperatureMeasurer;
    }
    
    //## auto_generated 
    public void _setItsTemperatureMeasurer(TemperatureMeasurer p_TemperatureMeasurer) {
        if(itsTemperatureMeasurer != null)
            {
                itsTemperatureMeasurer.__setParent(null);
            }
        __setItsTemperatureMeasurer(p_TemperatureMeasurer);
    }
    
    //## auto_generated 
    public TemperatureMeasurer newItsTemperatureMeasurer(RiJThread p_thread) {
        itsTemperatureMeasurer = new TemperatureMeasurer(p_thread);
        itsTemperatureMeasurer._setParent(this);
        return itsTemperatureMeasurer;
    }
    
    //## auto_generated 
    public void deleteItsTemperatureMeasurer() {
        itsTemperatureMeasurer.__setParent(null);
        itsTemperatureMeasurer=null;
    }
    
    //## auto_generated 
    protected void initRelations(RiJThread p_thread) {
        itsAC = newItsAC(p_thread);
        itsHeater = newItsHeater(p_thread);
        itsTemperatureMeasurer = newItsTemperatureMeasurer(p_thread);
    }
    
    //## auto_generated 
    public boolean startBehavior() {
        boolean done = true;
        done &= itsAC.startBehavior();
        done &= itsHeater.startBehavior();
        done &= itsTemperatureMeasurer.startBehavior();
        done &= reactive.startBehavior();
        return done;
    }
    
    //## ignore 
    public class Reactive extends RiJStateReactive {
        
        // Default constructor 
        public Reactive() {
            this(RiJMainThread.instance());
        }
        
        
        // Constructors
        
        public  Reactive(RiJThread p_thread) {
            super(p_thread);
            initStatechart();
        }
        
        //## statechart_method 
        public boolean isIn(int state) {
            if(AwaitMalfunctions_subState == state)
                {
                    return true;
                }
            if(state_1 == state)
                {
                    return isIn(Workflow);
                }
            if(state_1_subState == state)
                {
                    return true;
                }
            if(AwaitModules_subState == state)
                {
                    return true;
                }
            if(state_13 == state)
                {
                    return isIn(Workflow);
                }
            if(state_13_subState == state)
                {
                    return true;
                }
            if(state_2 == state)
                {
                    return isIn(Workflow);
                }
            if(state_2_subState == state)
                {
                    return true;
                }
            if(rootState_subState == state)
                {
                    return true;
                }
            return false;
        }
        
        //## statechart_method 
        public boolean isCompleted(int state) {
            if(AwaitMalfunctions == state)
                {
                    return ( isIn(terminationstate_8) );
                }
            if(AwaitModules == state)
                {
                    return ( isIn(terminationstate_16) );
                }
            if(state_2 == state)
                {
                    return ( isIn(terminationstate_10) );
                }
            if(Workflow == state)
                {
                    if(isCompleted(state_2) == false)
                        {
                            return false;
                        }
                    return true;
                }
            return true;
        }
        
        //## statechart_method 
        public void rootState_entDef() {
            {
                rootState_enter();
                rootStateEntDef();
            }
        }
        
        //## statechart_method 
        public int rootState_dispatchEvent(short id) {
            int res = RiJStateReactive.TAKE_EVENT_NOT_CONSUMED;
            if(rootState_active == Workflow)
                {
                    res = Workflow_dispatchEvent(id);
                }
            return res;
        }
        
        //## statechart_method 
        public int Workflow_dispatchEvent(short id) {
            int res = RiJStateReactive.TAKE_EVENT_NOT_CONSUMED;
            if(state_1_dispatchEvent(id) >= 0)
                {
                    res = RiJStateReactive.TAKE_EVENT_COMPLETE;
                    if(!isIn(Workflow))
                        {
                            return res;
                        }
                }
            if(state_2_dispatchEvent(id) >= 0)
                {
                    res = RiJStateReactive.TAKE_EVENT_COMPLETE;
                    if(!isIn(Workflow))
                        {
                            return res;
                        }
                }
            if(state_13_dispatchEvent(id) >= 0)
                {
                    res = RiJStateReactive.TAKE_EVENT_COMPLETE;
                    if(!isIn(Workflow))
                        {
                            return res;
                        }
                }
            if(res == RiJStateReactive.TAKE_EVENT_NOT_CONSUMED)
                {
                    res = Workflow_takeEvent(id);
                }
            return res;
        }
        
        //## statechart_method 
        public int state_2_dispatchEvent(short id) {
            int res = RiJStateReactive.TAKE_EVENT_NOT_CONSUMED;
            switch (state_2_active) {
                case terminationstate_10:
                {
                    res = terminationstate_10_takeEvent(id);
                }
                break;
                case Work:
                {
                    res = Work_takeEvent(id);
                }
                break;
                case Begin:
                {
                    res = Begin_takeEvent(id);
                }
                break;
                default:
                    break;
            }
            return res;
        }
        
        //## statechart_method 
        public int state_13_dispatchEvent(short id) {
            int res = RiJStateReactive.TAKE_EVENT_NOT_CONSUMED;
            switch (state_13_active) {
                case AwaitModule:
                {
                    res = AwaitModule_takeEvent(id);
                }
                break;
                case terminationstate_16:
                {
                    res = terminationstate_16_takeEvent(id);
                }
                break;
                default:
                    break;
            }
            return res;
        }
        
        //## statechart_method 
        public int state_1_dispatchEvent(short id) {
            int res = RiJStateReactive.TAKE_EVENT_NOT_CONSUMED;
            switch (state_1_active) {
                case AwaitMalfunction:
                {
                    res = AwaitMalfunction_takeEvent(id);
                }
                break;
                case terminationstate_8:
                {
                    res = terminationstate_8_takeEvent(id);
                }
                break;
                case ShuttingDown:
                {
                    res = ShuttingDown_takeEvent(id);
                }
                break;
                default:
                    break;
            }
            return res;
        }
        
        //## auto_generated 
        protected void initStatechart() {
            rootState_subState = RiJNonState;
            rootState_active = RiJNonState;
            state_2_subState = RiJNonState;
            state_2_active = RiJNonState;
            state_13_subState = RiJNonState;
            state_13_active = RiJNonState;
            AwaitModules_subState = RiJNonState;
            state_1_subState = RiJNonState;
            state_1_active = RiJNonState;
            AwaitMalfunctions_subState = RiJNonState;
        }
        
        //## statechart_method 
        public void ShuttingDown_entDef() {
            ShuttingDown_enter();
        }
        
        //## statechart_method 
        public void terminationstate_16_exit() {
            terminationstate_16Exit();
        }
        
        //## statechart_method 
        public void Work_entDef() {
            Work_enter();
        }
        
        //## statechart_method 
        public void state_2Enter() {
        }
        
        //## statechart_method 
        public int AwaitMalfunctionTakeTemperatureMeasurerBroken() {
            int res = RiJStateReactive.TAKE_EVENT_NOT_CONSUMED;
            AwaitMalfunction_exit();
            //#[ transition Workflow.state_1.AwaitMalfunctions.1 
            System.out.println("MALFUNCTION: Temperature measurement module is broken. Shutting down!");
            //#]
            ShuttingDown_entDef();
            res = RiJStateReactive.TAKE_EVENT_COMPLETE;
            return res;
        }
        
        //## statechart_method 
        public void terminationstate_8_entDef() {
            terminationstate_8_enter();
        }
        
        //## statechart_method 
        public void state_1Enter() {
        }
        
        //## statechart_method 
        public void AwaitModulesEnter() {
            itsRiJThread.schedTimeout(200, DecisionMaker_Timeout_AwaitModules_id, this, null);
        }
        
        //## statechart_method 
        public void state_13_entDef() {
            state_13_enter();
            state_13EntDef();
        }
        
        //## statechart_method 
        public void AwaitMalfunctionEnter() {
        }
        
        //## statechart_method 
        public void ShuttingDown_enter() {
            AwaitMalfunctions_subState = ShuttingDown;
            state_1_active = ShuttingDown;
            ShuttingDownEnter();
        }
        
        //## statechart_method 
        public void AwaitModule_enter() {
            AwaitModules_subState = AwaitModule;
            state_13_active = AwaitModule;
            AwaitModuleEnter();
        }
        
        //## statechart_method 
        public int AwaitMalfunction_takeEvent(short id) {
            int res = RiJStateReactive.TAKE_EVENT_NOT_CONSUMED;
            if(event.isTypeOf(ACBroken.ACBroken_Default_id))
                {
                    res = AwaitMalfunctionTakeACBroken();
                }
            else if(event.isTypeOf(HeaterBroken.HeaterBroken_Default_id))
                {
                    res = AwaitMalfunctionTakeHeaterBroken();
                }
            else if(event.isTypeOf(TemperatureMeasurerBroken.TemperatureMeasurerBroken_Default_id))
                {
                    res = AwaitMalfunctionTakeTemperatureMeasurerBroken();
                }
            
            if(res == RiJStateReactive.TAKE_EVENT_NOT_CONSUMED)
                {
                    res = AwaitMalfunctions_takeEvent(id);
                }
            return res;
        }
        
        //## statechart_method 
        public int AwaitMalfunctionTakeACBroken() {
            int res = RiJStateReactive.TAKE_EVENT_NOT_CONSUMED;
            AwaitMalfunction_exit();
            //#[ transition Workflow.state_1.AwaitMalfunctions.4 
            System.out.println("MALFUNCTION: AC module is broken. Shutting down!");
            //#]
            ShuttingDown_entDef();
            res = RiJStateReactive.TAKE_EVENT_COMPLETE;
            return res;
        }
        
        //## statechart_method 
        public void AwaitMalfunction_entDef() {
            AwaitMalfunction_enter();
        }
        
        //## statechart_method 
        public void ShuttingDownEnter() {
            itsRiJThread.schedTimeout(5000, DecisionMaker_Timeout_ShuttingDown_id, this, null);
        }
        
        //## statechart_method 
        public void AwaitMalfunctionsEnter() {
        }
        
        //## statechart_method 
        public void state_13_enter() {
            state_13Enter();
        }
        
        //## statechart_method 
        public void terminationstate_10Enter() {
            //#[ state Workflow.state_2.terminationstate_10.(Entry) 
            System.exit(-1);
            //#]
        }
        
        //## statechart_method 
        public int WorkTakeNull() {
            int res = RiJStateReactive.TAKE_EVENT_NOT_CONSUMED;
            Work_exit();
            Begin_entDef();
            res = RiJStateReactive.TAKE_EVENT_COMPLETE;
            return res;
        }
        
        //## statechart_method 
        public void state_2_exit() {
            switch (state_2_subState) {
                case terminationstate_10:
                {
                    terminationstate_10_exit();
                }
                break;
                case Work:
                {
                    Work_exit();
                }
                break;
                case Begin:
                {
                    Begin_exit();
                }
                break;
                default:
                    break;
            }
            state_2_subState = RiJNonState;
            state_2Exit();
        }
        
        //## statechart_method 
        public void AwaitMalfunction_enter() {
            AwaitMalfunctions_subState = AwaitMalfunction;
            state_1_active = AwaitMalfunction;
            AwaitMalfunctionEnter();
        }
        
        //## statechart_method 
        public int ShuttingDown_takeEvent(short id) {
            int res = RiJStateReactive.TAKE_EVENT_NOT_CONSUMED;
            if(event.isTypeOf(RiJEvent.TIMEOUT_EVENT_ID))
                {
                    res = ShuttingDownTakeRiJTimeout();
                }
            
            if(res == RiJStateReactive.TAKE_EVENT_NOT_CONSUMED)
                {
                    res = AwaitMalfunctions_takeEvent(id);
                }
            return res;
        }
        
        //## statechart_method 
        public void state_1_exit() {
            if(state_1_subState == AwaitMalfunctions)
                {
                    AwaitMalfunctions_exit();
                }
            state_1_subState = RiJNonState;
            state_1Exit();
        }
        
        //## statechart_method 
        public void state_1_entDef() {
            state_1_enter();
            state_1EntDef();
        }
        
        //## statechart_method 
        public int AwaitModuleTakeACSYN() {
            int res = RiJStateReactive.TAKE_EVENT_NOT_CONSUMED;
            AwaitModule_exit();
            //#[ transition Workflow.state_13.AwaitModules.3 
            itsAC.gen(new ACSYNACK());
            //#]
            terminationstate_16_entDef();
            res = RiJStateReactive.TAKE_EVENT_COMPLETE;
            return res;
        }
        
        //## statechart_method 
        public void AwaitModules_exit() {
            switch (AwaitModules_subState) {
                case AwaitModule:
                {
                    AwaitModule_exit();
                }
                break;
                case terminationstate_16:
                {
                    terminationstate_16_exit();
                }
                break;
                default:
                    break;
            }
            AwaitModules_subState = RiJNonState;
            AwaitModulesExit();
        }
        
        //## statechart_method 
        public void terminationstate_10Exit() {
        }
        
        //## statechart_method 
        public void WorkflowExit() {
        }
        
        //## statechart_method 
        public void AwaitMalfunction_exit() {
            AwaitMalfunctionExit();
        }
        
        //## statechart_method 
        public int Begin_takeEvent(short id) {
            int res = RiJStateReactive.TAKE_EVENT_NOT_CONSUMED;
            if(event.isTypeOf(RiJEvent.TIMEOUT_EVENT_ID))
                {
                    res = BeginTakeRiJTimeout();
                }
            
            if(res == RiJStateReactive.TAKE_EVENT_NOT_CONSUMED)
                {
                    res = state_2_takeEvent(id);
                }
            return res;
        }
        
        //## statechart_method 
        public void terminationstate_10_enter() {
            state_2_subState = terminationstate_10;
            state_2_active = terminationstate_10;
            terminationstate_10Enter();
        }
        
        //## statechart_method 
        public int ShuttingDownTakeRiJTimeout() {
            int res = RiJStateReactive.TAKE_EVENT_NOT_CONSUMED;
            if(event.getTimeoutId() == DecisionMaker_Timeout_ShuttingDown_id)
                {
                    ShuttingDown_exit();
                    //#[ transition Workflow.state_1.AwaitMalfunctions.2 
                    isBroken = true;
                    //#]
                    terminationstate_8_entDef();
                    res = RiJStateReactive.TAKE_EVENT_COMPLETE;
                }
            return res;
        }
        
        //## statechart_method 
        public void ShuttingDown_exit() {
            ShuttingDownExit();
        }
        
        //## statechart_method 
        public void AwaitMalfunctions_exit() {
            switch (AwaitMalfunctions_subState) {
                case AwaitMalfunction:
                {
                    AwaitMalfunction_exit();
                }
                break;
                case terminationstate_8:
                {
                    terminationstate_8_exit();
                }
                break;
                case ShuttingDown:
                {
                    ShuttingDown_exit();
                }
                break;
                default:
                    break;
            }
            AwaitMalfunctions_subState = RiJNonState;
            AwaitMalfunctionsExit();
        }
        
        //## statechart_method 
        public void AwaitMalfunctionsExit() {
        }
        
        //## statechart_method 
        public void AwaitModules_entDef() {
            AwaitModules_enter();
            
            AwaitModule_entDef();
        }
        
        //## statechart_method 
        public void state_13EntDef() {
            AwaitModules_entDef();
        }
        
        //## statechart_method 
        public void terminationstate_10_exit() {
            terminationstate_10Exit();
        }
        
        //## statechart_method 
        public int Work_takeEvent(short id) {
            int res = RiJStateReactive.TAKE_EVENT_NOT_CONSUMED;
            if(event.isTypeOf(RiJEvent.NULL_EVENT_ID))
                {
                    res = WorkTakeNull();
                }
            
            if(res == RiJStateReactive.TAKE_EVENT_NOT_CONSUMED)
                {
                    res = state_2_takeEvent(id);
                }
            return res;
        }
        
        //## statechart_method 
        public int rootState_takeEvent(short id) {
            int res = RiJStateReactive.TAKE_EVENT_NOT_CONSUMED;
            return res;
        }
        
        //## statechart_method 
        public void AwaitMalfunctions_entDef() {
            AwaitMalfunctions_enter();
            
            AwaitMalfunction_entDef();
        }
        
        //## statechart_method 
        public int AwaitModulesTakeRiJTimeout() {
            int res = RiJStateReactive.TAKE_EVENT_NOT_CONSUMED;
            if(event.getTimeoutId() == DecisionMaker_Timeout_AwaitModules_id)
                {
                    AwaitModules_exit();
                    AwaitModules_entDef();
                    res = RiJStateReactive.TAKE_EVENT_COMPLETE;
                }
            return res;
        }
        
        //## statechart_method 
        public void state_13Enter() {
        }
        
        //## statechart_method 
        public int BeginTakeRiJTimeout() {
            int res = RiJStateReactive.TAKE_EVENT_NOT_CONSUMED;
            if(event.getTimeoutId() == DecisionMaker_Timeout_Begin_id)
                {
                    //## transition 3 
                    if(isBroken == true)
                        {
                            Begin_exit();
                            terminationstate_10_entDef();
                            res = RiJStateReactive.TAKE_EVENT_COMPLETE;
                        }
                    else
                        {
                            //## transition 4 
                            if(isBroken == false)
                                {
                                    Begin_exit();
                                    Work_entDef();
                                    res = RiJStateReactive.TAKE_EVENT_COMPLETE;
                                }
                        }
                }
            return res;
        }
        
        //## statechart_method 
        public void terminationstate_10_entDef() {
            terminationstate_10_enter();
        }
        
        //## statechart_method 
        public void Workflow_entDef() {
            Workflow_enter();
            state_1_entDef();
            state_2_entDef();
            state_13_entDef();
        }
        
        //## statechart_method 
        public void terminationstate_8Exit() {
        }
        
        //## statechart_method 
        public void state_1Exit() {
        }
        
        //## statechart_method 
        public void AwaitModules_enter() {
            state_13_subState = AwaitModules;
            AwaitModulesEnter();
        }
        
        //## statechart_method 
        public int state_2_takeEvent(short id) {
            int res = RiJStateReactive.TAKE_EVENT_NOT_CONSUMED;
            return res;
        }
        
        //## statechart_method 
        public void WorkflowEnter() {
        }
        
        //## statechart_method 
        public void rootState_enter() {
            rootStateEnter();
        }
        
        //## statechart_method 
        public void rootStateEnter() {
        }
        
        //## statechart_method 
        public void ShuttingDownExit() {
            itsRiJThread.unschedTimeout(DecisionMaker_Timeout_ShuttingDown_id, this);
        }
        
        //## statechart_method 
        public void terminationstate_8Enter() {
        }
        
        //## statechart_method 
        public void state_13Exit() {
        }
        
        //## statechart_method 
        public void Work_enter() {
            pushNullConfig();
            state_2_subState = Work;
            state_2_active = Work;
            WorkEnter();
        }
        
        //## statechart_method 
        public void WorkEnter() {
        }
        
        //## statechart_method 
        public void state_2Exit() {
        }
        
        //## statechart_method 
        public void terminationstate_8_enter() {
            AwaitMalfunctions_subState = terminationstate_8;
            state_1_active = terminationstate_8;
            terminationstate_8Enter();
        }
        
        //## statechart_method 
        public void terminationstate_16Exit() {
        }
        
        //## statechart_method 
        public void terminationstate_16_enter() {
            AwaitModules_subState = terminationstate_16;
            state_13_active = terminationstate_16;
            terminationstate_16Enter();
        }
        
        //## statechart_method 
        public void terminationstate_16_entDef() {
            terminationstate_16_enter();
        }
        
        //## statechart_method 
        public void state_13_exit() {
            if(state_13_subState == AwaitModules)
                {
                    AwaitModules_exit();
                }
            state_13_subState = RiJNonState;
            state_13Exit();
        }
        
        //## statechart_method 
        public void state_2_entDef() {
            state_2_enter();
            state_2EntDef();
        }
        
        //## statechart_method 
        public void Workflow_enter() {
            rootState_subState = Workflow;
            rootState_active = Workflow;
            WorkflowEnter();
        }
        
        //## statechart_method 
        public int AwaitModule_takeEvent(short id) {
            int res = RiJStateReactive.TAKE_EVENT_NOT_CONSUMED;
            if(event.isTypeOf(HeaterSYN.HeaterSYN_Default_id))
                {
                    res = AwaitModuleTakeHeaterSYN();
                }
            else if(event.isTypeOf(ACSYN.ACSYN_Default_id))
                {
                    res = AwaitModuleTakeACSYN();
                }
            else if(event.isTypeOf(TMSYN.TMSYN_Default_id))
                {
                    res = AwaitModuleTakeTMSYN();
                }
            
            if(res == RiJStateReactive.TAKE_EVENT_NOT_CONSUMED)
                {
                    res = AwaitModules_takeEvent(id);
                }
            return res;
        }
        
        //## statechart_method 
        public void AwaitModuleExit() {
        }
        
        //## statechart_method 
        public void BeginEnter() {
            itsRiJThread.schedTimeout(200, DecisionMaker_Timeout_Begin_id, this, null);
        }
        
        //## statechart_method 
        public int terminationstate_10_takeEvent(short id) {
            int res = RiJStateReactive.TAKE_EVENT_NOT_CONSUMED;
            res = state_2_takeEvent(id);
            return res;
        }
        
        //## statechart_method 
        public void Workflow_exit() {
            state_1_exit();
            state_2_exit();
            state_13_exit();
            WorkflowExit();
        }
        
        //## statechart_method 
        public void rootStateEntDef() {
            Workflow_entDef();
        }
        
        //## statechart_method 
        public int AwaitMalfunctionTakeHeaterBroken() {
            int res = RiJStateReactive.TAKE_EVENT_NOT_CONSUMED;
            AwaitMalfunction_exit();
            //#[ transition Workflow.state_1.AwaitMalfunctions.3 
            System.out.println("MALFUNCTION: Heater module is broken. Shutting down!");
            //#]
            ShuttingDown_entDef();
            res = RiJStateReactive.TAKE_EVENT_COMPLETE;
            return res;
        }
        
        //## statechart_method 
        public void terminationstate_8_exit() {
            terminationstate_8Exit();
        }
        
        //## statechart_method 
        public void AwaitMalfunctions_enter() {
            state_1_subState = AwaitMalfunctions;
            AwaitMalfunctionsEnter();
        }
        
        //## statechart_method 
        public void state_1_enter() {
            state_1Enter();
        }
        
        //## statechart_method 
        public void AwaitModuleEnter() {
        }
        
        //## statechart_method 
        public int terminationstate_16_takeEvent(short id) {
            int res = RiJStateReactive.TAKE_EVENT_NOT_CONSUMED;
            res = AwaitModules_takeEvent(id);
            return res;
        }
        
        //## statechart_method 
        public void Begin_entDef() {
            Begin_enter();
        }
        
        //## statechart_method 
        public void Work_exit() {
            popNullConfig();
            WorkExit();
        }
        
        //## statechart_method 
        public int state_1_takeEvent(short id) {
            int res = RiJStateReactive.TAKE_EVENT_NOT_CONSUMED;
            return res;
        }
        
        //## statechart_method 
        public int AwaitModuleTakeTMSYN() {
            int res = RiJStateReactive.TAKE_EVENT_NOT_CONSUMED;
            AwaitModule_exit();
            //#[ transition Workflow.state_13.AwaitModules.1 
            itsTemperatureMeasurer.gen(new TMSYNACK());
            //#]
            terminationstate_16_entDef();
            res = RiJStateReactive.TAKE_EVENT_COMPLETE;
            return res;
        }
        
        //## statechart_method 
        public void Begin_enter() {
            state_2_subState = Begin;
            state_2_active = Begin;
            BeginEnter();
        }
        
        //## statechart_method 
        public void state_2_enter() {
            state_2Enter();
        }
        
        //## statechart_method 
        public int Workflow_takeEvent(short id) {
            int res = RiJStateReactive.TAKE_EVENT_NOT_CONSUMED;
            return res;
        }
        
        //## statechart_method 
        public void AwaitMalfunctionExit() {
        }
        
        //## statechart_method 
        public int terminationstate_8_takeEvent(short id) {
            int res = RiJStateReactive.TAKE_EVENT_NOT_CONSUMED;
            res = AwaitMalfunctions_takeEvent(id);
            return res;
        }
        
        //## statechart_method 
        public void terminationstate_16Enter() {
        }
        
        //## statechart_method 
        public int state_13_takeEvent(short id) {
            int res = RiJStateReactive.TAKE_EVENT_NOT_CONSUMED;
            return res;
        }
        
        //## statechart_method 
        public void Begin_exit() {
            BeginExit();
        }
        
        //## statechart_method 
        public void BeginExit() {
            itsRiJThread.unschedTimeout(DecisionMaker_Timeout_Begin_id, this);
        }
        
        //## statechart_method 
        public void rootStateExit() {
        }
        
        //## statechart_method 
        public int AwaitMalfunctions_takeEvent(short id) {
            int res = RiJStateReactive.TAKE_EVENT_NOT_CONSUMED;
            res = state_1_takeEvent(id);
            return res;
        }
        
        //## statechart_method 
        public void state_1EntDef() {
            AwaitMalfunctions_entDef();
        }
        
        //## statechart_method 
        public void AwaitModule_exit() {
            AwaitModuleExit();
        }
        
        //## statechart_method 
        public void WorkExit() {
        }
        
        //## statechart_method 
        public int AwaitModuleTakeHeaterSYN() {
            int res = RiJStateReactive.TAKE_EVENT_NOT_CONSUMED;
            AwaitModule_exit();
            //#[ transition Workflow.state_13.AwaitModules.2 
            itsHeater.gen(new HeaterSYNACK());
            //#]
            terminationstate_16_entDef();
            res = RiJStateReactive.TAKE_EVENT_COMPLETE;
            return res;
        }
        
        //## statechart_method 
        public void AwaitModule_entDef() {
            AwaitModule_enter();
        }
        
        //## statechart_method 
        public int AwaitModules_takeEvent(short id) {
            int res = RiJStateReactive.TAKE_EVENT_NOT_CONSUMED;
            if(event.isTypeOf(RiJEvent.TIMEOUT_EVENT_ID))
                {
                    res = AwaitModulesTakeRiJTimeout();
                }
            
            if(res == RiJStateReactive.TAKE_EVENT_NOT_CONSUMED)
                {
                    res = state_13_takeEvent(id);
                }
            return res;
        }
        
        //## statechart_method 
        public void AwaitModulesExit() {
            itsRiJThread.unschedTimeout(DecisionMaker_Timeout_AwaitModules_id, this);
        }
        
        //## statechart_method 
        public void state_2EntDef() {
            Begin_entDef();
        }
        
    }
}
/*********************************************************************
	File Path	: DefaultComponent/DefaultConfig/Default/DecisionMaker.java
*********************************************************************/

